int do_rm(char* pathName)
{
	int i;
	LOC inodeLoc, parentLoc;
	char fullPath[MAX_PATH_LENGTH];
	char buf[MAX_BLOCK_SIZE], *pnt = buf;
	char dirName[MAX_PATH_LENGTH];
	char baseName[EXT2_MAX_FILE_LENGTH];
	MINODE* inode, *parent;
	EXT2_DISK* diskInfo;
	
	if (pathName[0] != '/')
	{
		get_pwd_name(runningProc->cwd, fullPath);
		strcat(fullPath, pathName);
	}
	else
		strcpy(fullPath, pathName);
	
	inodeLoc = get_inode_number(fullPath);
	if (inodeLoc.inodeNum == 0)
	{
		printf("\"%s\" does not exist\n\n", fullPath);
		return -1;
	}
	
	inode = get_inode(inodeLoc.deviceHandle, inodeLoc.inodeNum);
	if (inode == 0)
		return -1;
		
	if (inode->refCount > 1)
	{
		printf("Cannot rm, file is busy with refCount = %d\n\n", inode->refCount);
		return -1;
	}
	
	if (S_ISDIR(inode->inode.i_mode))
	{
		printf("Cannot rm a directory, use rmdir instead\n\n");
		return -1;
	}
	
	if ((runningProc->uid != 0) && (runningProc->uid != inode->inode.i_uid))
	{
		printf("Current process does not have access to directory\n\n");
		return -1;
	}
	
	if (get_device_info(inode->location.deviceHandle, &diskInfo) == -1)
		return -1;
		
	dir_name(fullPath, dirName);
	base_name(fullPath, baseName);
	parentLoc = get_inode_number(dirName);
	parent = get_inode(parentLoc.deviceHandle, parentLoc.inodeNum);
	
	if (remove_name_from_parent(parent, inode->location.inodeNum, baseName) == -1)
		return -1;
	
	truncate_file(inode);
	deallocate_inode(inode->location.deviceHandle, inode->location.inodeNum);
		
	inode->refCount = 0;
	
	parent->inode.i_links_count--;
	parent->inode.i_atime = time(0);
	parent->dirty = true;
	
	put_inode(parent);
	return 1;
}
